package com.xxwy.springcloud.controller;

import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.security.Principal;
import java.util.HashMap;
import java.util.Map;

/**
 * @author xxwy
 * on 2018/10/12 0012
 */
@RestController
public class UserController {

    @RequestMapping("/oauth/unauthorized")
    @ResponseBody
    public ResponseEntity<Map> loginPage() {
        HashMap<String, Object> map = new HashMap<>();
        map.put("code",100);
        map.put("msg","错误的请求");
        map.put("timestamp",System.currentTimeMillis());
        return new ResponseEntity<>(map,HttpStatus.UNAUTHORIZED);
    }

    @GetMapping("/user")
    public Principal user(Principal user){
        return user;
    }
}
